package com.astrob.view;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.astrob.naviframe.Start;
import com.astrob.nhcmap.R;
public class ZoomView extends LinearLayout  {

	private Context mContext;
	private TextView mZoomIn = null;
	private TextView mZoomOut = null;

	public ZoomView(Context context) {
		super(context);
		mContext = context;
		initAbs();
	}

	public ZoomView(Context context, AttributeSet attrs) {
		super(context, attrs);
		mContext = context;
		initAbs();
	}

	private void initAbs() {
		View convertView = LinearLayout.inflate(mContext,
				R.layout.zoom_view, this);
		mZoomIn = (TextView) convertView
				.findViewById(R.id.btnzoomin);
		mZoomOut = (TextView) convertView
				.findViewById(R.id.btnzoomout);
	}

	public void setOnClickListener(@Nullable OnClickListener l) {
		mZoomIn.setOnClickListener(l);
		mZoomOut.setOnClickListener(l);
	}

	// status == 1 zoomin max
	// status == -1 zoomout max
	// == 0 normal
	public void updateState(int status) {
		if (status == 1) {
			//mZoomIn.setButtonMode(ThreeModeButton.BUTTON_MODE_DISABLE);
			mZoomIn.setEnabled(false);
			mZoomOut.setEnabled(true);
		} else if (status == -1) {
			//mZoomIn.setButtonMode(ThreeModeButton.BUTTON_MODE_UP);
			mZoomIn.setEnabled(true);
			mZoomOut.setEnabled(false);
		} else {
			mZoomIn.setEnabled(true);
			mZoomOut.setEnabled(true);
		}
	}

	public void recycle() {
		// TODO Auto-generated method stub

	}

	public void updateState() {
		double scale = Start.getInstance().MapKit().getScale();
		if (scale < 20) {
			updateState(-1);
		} else if (scale >= 400000.0) {
			updateState(1);
		} else {
			updateState(0);
		}
		
	}

}
